<?php

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
} 

class table_common_attach_qrcode extends discuz_table{
	public function __construct() {
        parent::__construct();
		$this->_table = 'common_attach_qrcode';
		$this->_pk    = 'id';
	}

    public function fetch($where,$field='*') {
		$whereStr = '';
		if(!empty($where)){
			$whereStr = ' WHERE '.$where;
		}
		return DB::fetch_first("SELECT $field FROM %t $whereStr", array($this->_table));
	}

	public function count_by_where($where) {
		$whereStr = '';
		if(!empty($where)){
			$whereStr = ' WHERE '.$where;
		}
		$count = (int) DB::result_first("SELECT count(*) FROM ".DB::table($this->_table) ." $whereStr");
		return $count;
	}
    
    public function fetch_by_keyword($keyword,$field='*') {
		return DB::fetch_first("SELECT $field FROM %t WHERE keyword LIKE %s AND status=1", array($this->_table, '%'.$keyword.'%'));
	}

	public function update_by_where($data,$where) {
		return DB::update($this->_table, $data, $where);
	}



	public function delete($where) {
		$whereStr = '';
		if(!empty($where)){
			$whereStr = ' WHERE '.$where;
		}
		return DB::query("DELETE FROM %t $whereStr", array($this->_table));
	}

}


?>
